<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="com.sms.project.*" %>

<%--
	project/headman/project.jsp
 --%>

<%	//清除内存
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0); 
%> 

<%
	request.setCharacterEncoding("utf-8");
	String userno = (String)session.getAttribute("userno");
	String role = (String)session.getAttribute("role");
	
	String progress = request.getParameter("progress");
	String progress2 = request.getParameter("progress2");
	String sa[] = new String[3];
	String sb[] = new String[3];
	if(progress != null) {
		if(progress.trim().equals("already")) {
			sa[0] = "selected";
		} else if(progress.trim().equals("unalready")){
			sa[1] = "selected";
		} else {
			sa[2] = "selected";
		}
	} 
	
	if(progress2 != null) {
		if(progress2.trim().equals("already")) {
			sb[0] = "selected";
		} else if(progress2.trim().equals("unalready")){
			sb[1] = "selected";
		} else {
			sb[2] = "selected";
		}
	}
	
 %>


<%@ page import="com.sms.project.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div style="height:20px;" >&nbsp;</div>
<div style="margin:10px auto; width:600px; font-size:15px;">
项目进度:<select id="progress">
	<option value="all" <%= sa[2] %>>全部</option>
	<option value="unalready" <%= sa[1] %>>未完成</option>
	<option value="already"  <%= sa[0] %>>已完成</option>
</select>
<input type="submit"  id='pro-search'  value="搜索" />
</div>
<!-- <div class="tip">说明：项目组长可以管理相应项目的组员，发布相应的作业给项目成员，查看成员的汇报，向老师汇报项目进度<br />而项目中的组员只能查看，接收，提交任务，和添加汇报</div>
 -->
<form  id="all-project1">
<table class="project1" cellpadding="0" cellspacing="0">
</table>
</form>
<br/><br/>

<div style="margin:10px auto; width:600px; font-size:15px;">
项目进度:<select id="progress2">
	<option value="all" <%= sb[2] %>>全部</option>
	<option value="unalready" <%= sb[1] %>>未完成</option>
	<option value="already"  <%= sb[0] %>>已完成</option>
</select>
<input type="submit"  id='pro-search2'  value="搜索" />
</div>

<form  id="all-project2">
<table class="project2" cellpadding="0" cellspacing="0">
</table>
</form>

<br/>
<div id="dd"></div>
<div id="aa"></div>

<script type="text/javascript">
$('.project1').datagrid({
	url:'project/headman/query-lproject.jsp?progress=' 
                                     	+ $('#progress option:selected').attr('value'), 
	title:"项目身份：组长",
	columns:[[
			{field:'code',title:'项目编号',width:100},
			{field:'name',title:'项目名称',width:220},
			{field:'status',title:'项目进度',width:100},
			{field:'prodetail',title:'详细信息',width:100},
			{field:'repdetail',title:'任务/信息交流',width:100},	
		]],
	pagination:true,
	onDblClickCell:function(rowIndex, field, value){
		$(this).click(function(){
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});
		})
		if(field=='prodetail'){
			//判断一下如果是组长还是组员，然后选择不同的链接if,else
			 $('#dd').dialog({
		         title:"项目详情",
				 zIndex:9001,
				 width:820, height:490,
				 top:140,left:365,
				 cache:false,
				 resizable:true,
				href:'project/headman/item-details.jsp?row='+rowIndex + '&progress=' 
                                     	+ $('#progress option:selected').attr('value') //！！！！//组长的链接后台请注意获取的时候检测一下
		   });
		    $('#dd').dialog('refresh','project/headman/item-details.jsp?row='+rowIndex + '&progress=' 
                                     	+ $('#progress option:selected').attr('value') )
			}	   
	   else if(field=='repdetail'){
			    $('#dd').dialog({
		         title:"汇报详情",
				 zIndex:9001,
				width:820, height:490,
				 top:140,left:365,
				 maximizable:true,
				 cache:false,
				 resizable:true,
				href:'project/headman/report-detail.jsp?row='+rowIndex + '&progress=' 
                                     	+ $('#progress option:selected').attr('value') //没有权限，只要是自己参与的项目都能看到，能够回复和发表新汇报
		   });
		   		$('#dd').dialog('refresh','project/headman/report-detail.jsp?row='+rowIndex + '&progress=' 
                                     	+ $('#progress option:selected').attr('value') )
			   }
	}

})


$('.project2').datagrid({
	url:'project/headman/query-sproject.jsp?progress=' 
                                     	+ "&progress2=" + $('#progress2 option:selected').attr('value'),
	title:"项目身份：组员",
	columns:[[
			{field:'code',title:'项目编号',width:100},
			{field:'name',title:'项目名称',width:220},
			{field:'status',title:'项目进度',width:100},
			{field:'prodetail',title:'详细信息',width:100},
			{field:'repdetail',title:'任务/信息交流',width:100},	
		]],
	pagination:true,
	onDblClickCell:function(rowIndex, field, value){
		$(this).click(function(){
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});
		})
		if(field=='prodetail'){
			 $('#dd').dialog({
		         title:"项目详情",
				 zIndex:9001,
				 width:820, height:490,
				 top:140,left:365,
				 cache:false,
				 resizable:true,
				href:'project/headman/item-sdetails.jsp?row='+rowIndex + '&playrole=member&progress=' 
                                     	+ $('#progress2 option:selected').attr('value') //！！！！//组长的链接后台请注意获取的时候检测一下
		   });
		   		$('#dd').dialog('refresh','project/headman/item-sdetails.jsp?row='+rowIndex + '&playrole=member&progress=' 
                                     	+ $('#progress2 option:selected').attr('value') )
		   
			}
		   else if(field=='repdetail'){
			    $('#dd').dialog({
		         title:"汇报详情",
				 zIndex:9001,
				 width:820, height:490,
				 top:140,left:365,
				 maximizable:true,
				 cache:false,
				 resizable:true,
				href:'project/headman/report-sdetail.jsp?row='+rowIndex + '&progress=' 
                                     	+ $('#progress2 option:selected').attr('value') //没有权限，只要是自己参与的项目都能看到，能够回复和发表新汇报
		   });
		   $('#dd').dialog('refresh','project/headman/report-sdetail.jsp?row='+rowIndex + '&progress=' 
                                     	+ $('#progress2 option:selected').attr('value') )
			   }
	}

})

/*项目详情*/
$('.datagrid-body tr').each(function(){
	$('this').children().eq(3).click(function(){
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});
		 $('#dd').dialog({
		         title:"项目详情",
				 zIndex:9001,
				 width:820, height:490,
				 top:140,left:365,
				 cache:false,
				 resizable:true,
				href:'project/headman/item-details.jsp'
		   });
		});
	})
	
/*项目任务*/
$('.datagrid-body tr').each(function(){
	$('this').children().eq(5).click(function(){
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});
		  if($(this).text()=='项目任务管理'){
			  $('#dd').dialog({
				         title:"项目任务管理",
						  zIndex:9001,
						 width:820, height:490,
				 top:140,left:365,
						 cache:false,
						  resizable:true,
						href:'project/headman/task.jsp' //注意变量i的传输
						 });
			} else if($(this).text()=='项目任务查看'){
			   $('#dd').dialog({
				         title:"项目任务查看",
						  zIndex:9001,
						 width:820, height:490,
				 		top:140,left:365,
						 cache:false,
						  resizable:true,
						href:'project/headman/my-task.html' //注意变量的传输
						 });
			  }
			
		});
	})	
	
/*汇报详情*/
$('.datagrid-body tr').each(function(){
	$('this').children().eq(6).click(function(){
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});  
		if($(this).text()=='添加汇报'){
			  $('#dd').dialog({
				         title:"汇报添加",
						  zIndex:9001,
						 width:820, height:490,
				 		top:140,left:365,
						 cache:false,
						  resizable:true,
						href:'project/headman/report-add.jsp?row=' + i //注意变量i的传输
						 });
		  }
		  else if($(this).text()=='汇报管理'){
			   $('#dd').dialog({
				         title:"汇报管理",
						  zIndex:9001,
						 width:820, height:490,
				 		top:140,left:365,
						 cache:false,
						  resizable:true,
						href:'project/headman/report-details.jsp?row=' + i //注意变量i的传输
						 });
		  }
				
		});
	})	
	
/*搜索处理*/
$("#pro-search, #pro-search2").click(function(){
	var tab = $(".easyui-tabs").tabs('getSelected');
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									options:{
								      cache:false,
                                     href:'project/headman/project.jsp?progress=' 
                                     	+ $('#progress option:selected').attr('value') 
                                     	+ "&progress2=" + $('#progress2 option:selected').attr('value')}
									}
										);  /*更新面板*/	
		
})
</script>
</body>
